<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
include_once "common.php";
class venue
{
    function venue()
    {
        global $baseinfo_c;
         $baseinfo_c =new baseinfo_common();
    }
    function insert($zh_hk,$cid,$en_us="",$zh_cn="",$telephones="",$address_en_us="",$address_zh_hk="",$address_zh_cn="",$urls="",$contact_person="",$delete_flag=0)
    {
        global $baseinfo_c;
        if($zh_hk==null || $zh_hk=='')
        {
            return 0;//error
        }
        $strSql="INSERT INTO venue(name_en_us,name_zh_hk,name_zh_cn,telephones,address_en_us,address_zh_hk,address_zh_cn,delete_flag,cid,urls,contact_person) VALUE ('"
                  .$baseinfo_c->utf8trim($en_us)."','".$baseinfo_c->utf8trim($zh_hk)."','".$baseinfo_c->utf8trim($zh_cn)."','". $baseinfo_c->utf8trim($telephones)."','". $baseinfo_c->utf8trim($address_en_us)."','"
                  . $baseinfo_c->utf8trim($address_zh_hk)."','". $baseinfo_c->utf8trim($address_zh_cn)."',". $baseinfo_c->utf8trim($delete_flag).",".$baseinfo_c->utf8trim( $cid). ",'".$baseinfo_c->utf8trim($urls)."','".$baseinfo_c->utf8trim($contact_person)."');";
        global $baseinfo_c;
        $baseinfo_c->execSql($strSql);
    }
    function delete($keyValue)
    {
         global $baseinfo_c;
         $baseinfo_c->deleteRecord("venue","vid",$baseinfo_c->utf8trim($keyValue));
    }
    function update($keyValue,$cid,$zh_hk,$en_us="",$zh_cn="",$telephones="",$address_en_us="",$address_zh_hk="",$address_zh_cn="",$urls="",$contact_person="",$delete_flag=0)
    {
        global $baseinfo_c;
        $strSql="UPDATE venue SET name_en_us='".$baseinfo_c->utf8trim($en_us)."',name_zh_hk='".$baseinfo_c->utf8trim($zh_hk)."',name_zh_cn='".$baseinfo_c->utf8trim($zh_cn)."'
            ,telephones='".$baseinfo_c->utf8trim($telephones)."',address_en_us='".$baseinfo_c->utf8trim($address_en_us)."',address_zh_hk='".$baseinfo_c->utf8trim($address_zh_hk)."'
            ,address_zh_cn='".$baseinfo_c->utf8trim($address_zh_cn)."',delete_flag='".$delete_flag."',cid='".$baseinfo_c->utf8trim($cid)."'
            ,urls='".$baseinfo_c->utf8trim($urls)."',contact_person='".$baseinfo_c->utf8trim($contact_person)."'
            WHERE vid=".$keyValue.";";
         $baseinfo_c->execSql($strSql);
    }
    function select($pageSize,$pageNo,$where="")
    {
         global $baseinfo_c;
         return $baseinfo_c->getPageRecords("venue","vid",$pageSize,$pageNo,$where);
    }
    function selectDetail($pageSize,$pageNo,$where="")
    {
         global $baseinfo_c;
         if($where=="")
         {
         $strSelectOrderBy="SELECT v.*,c.name_en_us AS c_en_us,c.name_zh_cn AS c_zh_cn,c.name_zh_hk AS c_zh_hk FROM venue v 
                            JOIN city c ON v.cid=c.cid
                            WHERE c.delete_flag=0 AND v.delete_flag=0
                            ORDER BY v.vid";
         }
         else
         {
             $where="v.name_zh_hk LIKE '%".$where."%'
            OR v.name_en_us LIKE '%".$where."%'
            OR v.name_zh_cn LIKE '%".$where."%'";
               $strSelectOrderBy="SELECT v.*,c.name_en_us AS c_en_us,c.name_zh_cn AS c_zh_cn,c.name_zh_hk AS c_zh_hk FROM venue v 
                            JOIN city c ON v.cid=c.cid
                            WHERE (c.delete_flag=0 AND v.delete_flag=0) AND (".$where.")
                            ORDER BY v.vid";
         }
         return $baseinfo_c->getSqlPageRecords($strSelectOrderBy,$pageSize,$pageNo);
    }
    function getTotalPages($pageSize,$where="")
    {
        if($where!="")
        {
            $where="name_zh_hk LIKE '%".$where."%'
            OR name_en_us LIKE '%".$where."%'
            OR name_zh_cn LIKE '%".$where."%'";
        }
         global $baseinfo_c;
         return $baseinfo_c->getTablePages("venue",$pageSize,$where);
    }
}
?>
